package org.example.controller;

import org.example.domain.entity.ShoppingCart;
import org.example.domain.entity.ShoppingCat;
import org.example.domain.model.Result;
import org.example.service.IShoppingService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("shoppingCartList")
@CrossOrigin("*")
public class ShoppingController {

    private IShoppingService shop;

    public ShoppingController(IShoppingService shop) {
        this.shop = shop;
    }

    @GetMapping
    public Result shoppingCartList(Integer userId){
        List<ShoppingCart> list = shop.queryAllCat(userId);
         return Result.buildSuccess(list);
    }
}
